/*
 * 
 * Copyright 2007 POB-Technology. All rights reserved.
 * POB-Technology PROPRIETARY/CONFIDENTIAL.
 * 
 * Test flash function
 */
#include <pob-eye.h>


//remove comment if you want test only the flash read test !
//#define TEST_FLASH_READ 1

int main(void)
{
	int i;
	unsigned char *data = "Hello world ! Write/Read test in flash of POB-EYE." ;
	unsigned char array[512];
	unsigned int len=0;
	int result;

	//init POB-EYE
	InitPOBEYE();

	//init flash function
	FlashInit();

	for(i=0;data[i]!=0;i++)
	{
		len++;
	}


#ifndef TEST_FLASH_READ

	//if the symbol TEST_FLASH_READ is not define, 
	// all the code between #ifndef ...#endif is compiled !


	//clear flash
	result = FlashErase();
	PrintTextOnPobTerminal("Erasing flash... %d", result );

	PrintTextOnPobTerminal("Len of data %d", len);

	//write flash
	result = FlashWrite(0,data,len);

	PrintTextOnPobTerminal("Writing flash... %d", result );

#endif	

	PrintTextOnPobTerminal("Reading flash...");

	//read flash
	FlashRead(0,0,array,len);
	array[len]=0;
	PrintTextOnPobTerminal("array=%s",array);


	return 0;
}
